package my.shadowsocks.client;

import io.netty.buffer.ByteBuf;

/**
 * @author fengbo
 * @date 2018/10/9
 */
public class InAbstractRelayHandler extends AbstractRelayHandler {

    private SocksServerConnectHandler connectHandler;

    InAbstractRelayHandler(SocksServerConnectHandler connectHandler) {
        this.connectHandler = connectHandler;
    }

    @Override
    protected void channelRead0(ByteBuf msg) {
        if (!msg.hasArray()) {
            int len = msg.readableBytes();
            byte[] arr = new byte[len];
            msg.getBytes(0, arr);
            connectHandler.sendLocal(arr, arr.length);
        }
    }
}
